#!/bin/bash

echo "Get version..."
# la date
VERS=`./retvers.pl`

echo "Cleaning..."
# on nettoie le bordel...
make -C ./source/  -f makefile clean >/dev/null

echo "Compressing backup..."
# on tar le projet
tar -cvzf $VERS.bkup.eirmulator3.tar.gz ./source/* ./windows/* ./backup ./changelog ./whatisaloutre ./Doxyfile ./utils/* ./retvers.pl >/dev/null

# on build les releases
./makerelease.sh >/dev/null

echo "Compressing linux release..."
# on tar la release linux
tar -cvzf $VERS.release.linux.eirmulator3.tar.gz ./release/linux/* >/dev/null

echo "Compressing winxp release..."
# on tar la release linux
tar -cvzf $VERS.release.winxp.eirmulator3.tar.gz ./release/winxp/* >/dev/null

echo "Envoi..."
# on l'envoie à l'enseirb
scp ./$VERS.bkup.eirmulator3.tar.gz ./$VERS.release.linux.eirmulator3.tar.gz ./$VERS.release.winxp.eirmulator3.tar.gz brossill@tanit.enseirb.fr:~/public_html/EIRMULATOR/sources/

echo "Suppression..."
# on vire le tar.gz local
rm -f ./$VERS.bkup.eirmulator3.tar.gz ./$VERS.release.{linux,winxp}.eirmulator3.tar.gz
